package org.luojs.stock_invest.factory.impl;

import org.luojs.stock_invest.factory.IStockTrendDao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StockTrendDaoImpl implements IStockTrendDao {

    @Override
    public List<Double> getRangeList(String stockKey) {
        List<Double> rangeList = new ArrayList<>();
        switch (stockKey) {
            case "sh.sz50":
                rangeList = Arrays.asList(//-0.55d, -0.1d, 0.31d, 0.5d, 0.02d, -0.62d, -0.33d, -0.55d, 1.28d, -0.47d, -0.03d,
                        0.88d, 0.85d, 0.28d, -0.3d, 0.46d, -1.07d, -0.85d, -1.53d, -2.01d, -0.93d, -0.49d, 1.44d, -0.53d,
                        1.9d, -1.13d, 0.41d, 0.36d, 0.35d, 1.88d, -0.05d, -0.22d, 0.31d, 1.37d, -1.85d, 0.83d, -0.7d, -0.4d,
                        0.59d, 0.79d, -0.1d, 0.95d, 1.24d, 0.85d, 0.02d, -0.4d, -0.43d, 1.43d, -0.57d, -1.52d, 0.59d, 0.08d,
                        0.22d, -1.1d, 0.31d, -0.38d, -0.03d, 0.05d, -1.08d, 0.85d, 0.02d, 0.61d, 1.44d, 1.02d, 0.06d, -0.35d,
                        0.23d, -1.61d, 0.19d, 0.15d, -0.64d, 0.61d, 0.27d, 0.48d, -0.44d, -0.54d, 0.09d, 1.62d, 0.65d, 0.59d,
                        -0.24d, 0.02d, -0.69d, -1.55d, 0.19d, -0.12d, 0.03d, -0.47d, 0.89d, 0.66d, -1.09d, -0.63d, -0.92d,
                        0.99d, -0.16d, -0.08d, -0.47d, -1.22d, 0.16d, 0.35d, -0.29d, 0.72d, 0.61d, -0.23d, 0.13d, 0.43d, -0.39d,
                        2.32d, -0.24d, 1.13d, -0.24d, -0.27d, -0.17d, -0.94d, 0.42d, -0.36d, 0.86d, 0.2d, 1.49d, 0.02d, 0.9d,
                        -0.41d, -0.7d, 0.56d, -1.18d, 0.98d, 0.01d, 0.73d, -0.31d, -0.73d, -0.49d, 0.33d, 0.42d, -1.76d, 0.19d,
                        -2.83d, -7d, 2.48d, 0.65d, 1.49d, -0.11d, -0.06d, 1.05d, 0.55d, -0.69d, 0.68d, 1.9d, -0.87d, -0.02d,
                        1.86d, -0.34d, -1.28d, -0.71d, -0.26d, 0.36d, -3.12d, 3.08d, 0.47d, 0.89d, 2.39d, -1.76d, -3.24d, 1.93d,
                        -1.23d, -1.61d, -1.52d, -3.74d, -0.31d, -2.23d, -2.13d, 2.28d, -2.62d, 3.12d, 2.3d, -0.4d, 0.45d, -0.42d,
                        -0.02d, -0.27d, 1.41d, -0.41d, 1.79d, -0.49d, 0.32d, -0.1d, -0.39d, 1.7d, -0.76d, 0.14d, 1.47d, 0.38d,
                        -1.25d, 0.71d, -0.23d, -0.77d, 1.05d, 0.71d, 0.7d, 0.6d, 0.07d, -0.33d, 0.65d, -0.04d, -0.08d, -0.07d,
                        -1.16d, -0.52d, 0.62d, 0.83d, -0.16d, -0.33d, -2.49d, 0.69d, -0.48d, 0.51d, -0.11d, 0.54d, 0.11d, -0.2d,
                        0.45d, 0.46d, 0.64d, -0.68d, -1.1d, 0.26d, -1.58d, 1.42d, 0.07d, 0.27d, 1.28d, -0.14d, 0.12d, 0.62d,
                        0.57d, 2.3d, 2.47d, 6.8d, 0.23d, 1.42d, 0.35d, -2.62d, 1.14d, -1.24d, -1.02d, -4.58d, 0.75d, 3.2d,
                        -0.03d, 0.14d, -0.22d, -3.83d, 0.16d, 0.72d, 1.8d, -0.37d, 0.55d, 0.98d, 0.95d, -0.6d, 0d, -0.86d
                );
                break;
            case "sz.cybz":
                rangeList = Arrays.asList(1.22d, 0.88d, -0.27d, 0.3d, 0.87d, -0.62d, 0.22d, -1.09d, -1.63d, -1.53d, -0.51d, 1.51d,
                        -1d, 2.14d, -1.01d, 0.81d, 1.24d, 0.79d, 3.5d, -0.69d, -0.11d, 0.23d, 0.13d, -0.91d, 1.17d, -0.18d, -0.27d,
                        -0.61d, 2.57d, 0.49d, 0.54d, 1.18d, 0.19d, 2.42d, -0.46d, -1.26d, 0.41d, 0.22d, -2.12d, 0.08d, 1.57d,
                        -0.03d, -1.22d, 0.61d, -1.3d, -2.92d, 1.46d, -1.21d, -0.67d, 0.36d, 2.75d, -0.01d, 0.75d, -1.1d, -0.27d,
                        0.11d, -0.58d, -0.25d, 1.36d, -0.99d, 0.22d, 1.3d, 1.74d, -1.05d, -0.15d, -0.76d, 0.94d, 0.77d, 0.79d,
                        -0.6d, 0.74d, -0.25d, -2.23d, -0.1d, 0.62d, 0.64d, -1.05d, 0.46d, 2.77d, -0.54d, -0.38d, -1.95d, -1.07d,
                        1.04d, -0.28d, -0.04d, -0.53d, 0.28d, 0.35d, -0.1d, 2.15d, 0.99d, -0.33d, 0.75d, -0.91d, 0.16d, 2d, 1.42d,
                        1.2d, -0.51d, -0.11d, -1.05d, -1.98d, 1.91d, 0.82d, 0.52d, -1.45d, 1.28d, 0.44d, 1.93d, 0.18d, 1.3d, 1.79d,
                        -1.61d, 2.71d, -0.47d, 1.62d, -0.65d, 0.09d, 0.3d, 0.13d, 2.57d, 0.76d, 1.37d, -3.32d, -6.85d, 4.84d, 3.02d,
                        3.74d, 0.18d, 1.31d, -0.67d, 2.8d, -0.99d, 0.22d, 3.72d, 1.15d, -1.45d, 2.21d, 1.82d, 1.68d, 1.03d, -4.66d,
                        0.73d, -5.7d, 3.08d, 1.78d, -0.18d, 1.85d, -0.75d, -4.55d, 2.66d, -2.2d, -2.64d, -0.75d, -5.9d, 0.36d,
                        -1.6d, 0.42d, 1.06d, -4.6d, 2.75d, 3.25d, -0.55d, -1.21d, -2.28d, 0.61d, -0.38d, 2.8d, -0.54d, 3.31d, -0.25d,
                        1.65d, -2.37d, -1.37d, 3.24d, -0.4d, 1.56d, 0.62d, 1.12d, -0.95d, 0.95d, -0.67d, -1.27d, 0.74d, 0.6d, -0.01d,
                        1.92d, 1.97d, -0.16d, 0.87d, -1.05d, 1.01d, 0.78d, -1.08d, 0.31d, -0.44d, 1.3d, -1.21d, -0.88d, -2.52d,
                        2.96d, -1.96d, -0.8d, 1.54d, 3.43d, -0.6d, -0.1d, 0.39d, 0.7d, -0.59d, 1.3d, 0.94d, -0.29d, 0.51d, 0.58d,
                        1.84d, 0.15d, 0.09d, 2.36d, 1.01d, 1.67d, 0.02d, -0.42d, 2.77d, 0.2d, 1.57d, 2.72d, 2.44d, 2.34d, 3.98d,
                        0.75d, 3.99d, -1.06d, -1.6d, -5.93d, 0.61d, 1.31d, 1.45d, 1.19d, 1.11d, -6.14d, 0.15d, 1.31d, 3.78d, -0.86d,
                        1.89d, 2.63d, -1.26d, 0.97d, -1.6d, -2.29d);
                break;
            case "sz.jdfa":
                rangeList = Arrays.asList(1.75d, 5.41d, -2.1d, 2.38d, -3.95d, -1.94d, -0.25d, -2.72d, -2.54d, -1.83d, -1.33d, 3.23d,
                        -2.87d, 3.49d, -1.3d, 1.58d, -0.26d, -0.78d, 2.88d, -0.76d, -0.77d, 2.84d, -0.25d, -2.27d, -0.77d, -1.82d,
                        -1.59d, -1.61d, 1.64d, 0.54d, 0d, 2.67d, 1.82d, 4.86d, -2.2d, 1d, -0.49d, 0d, -2.98d, -0.51d, 1.54d, -0.25d,
                        -1.02d, 0d, -3.33d, -1.59d, 1.35d, -0.27d, 0d, 0d, 0.53d, -0.27d, 1.06d, -1.58d, -0.53d, -0.54d, -1.62d,
                        -1.1d, 1.67d, 2.46d, -1.07d, -0.27d, 1.08d, -2.14d, -0.55d, -1.92d, 0.56d, 0.28d, 0.28d, -0.28d, 2.22d,
                        -1.36d, -1.93d, 2.81d, -0.55d, 3.3d, -1.86d, 0.81d, 0.27d, -1.88d, 0.27d, -0.54d, 1.64d, 4.04d, 0.78d, -1.29d,
                        1.56d, -0.26d, 1.8d, 2.02d, 0d, 0.74d, 1.23d, 0.24d, -3.15d, 0.25d, 2.49d, 6.81d, 8.2d, -1.89d, 0.64d, -0.21d,
                        -2.56d, 3.07d, 0.85d, 1.9d, -3.93d, -1.72d, -0.44d, 1.54d, 2.6d, -0.42d, -0.64d, 5.98d, 0.81d, -1d, -0.2d,
                        0.4d, -1.61d, 0.2d, -1.23d, 3.11d, -0.2d, -1.01d, -4.07d, -9.96d, 3.76d, 0.23d, 5.66d, -.21d, 1.93d, 0d,
                        0.21d, -0.84d, -0.85d, 4.91d, 3.05d, -1.98d, 7.66d, 0.19d, 7.48d, 1.39d, -7.89d, -1.49d, -7.37d, 3.67d, 0.2d,
                        -1.38d, 1.59d, 1.18d, -5.04d, 2.65d, -2.98d, -5.53d, -2.6d, -7.57d, 2.41d, -2.82d, 1.21d, 0.48d, -6.19d,
                        0.25d, 2.53d, -2.47d, 0d, -4.81d, -1.33d, 2.43d, 2.63d, -2.05d, 3.14d, 0d, -0.51d, -3.06d, -1.58d, 2.67d, 0d,
                        -0.78d, 2.1d, -1.03d, -1.3d, 0.26d, -1.05d, -1.86d, -0.81d, -3.54d, 0.85d, 5.32d, 1.6d, -1.31d, 2.39d, 2.33d,
                        -0.76d, -0.51d, 1.81d, -3.31d, 1.32d, 1.56d, -1.02d, -2.58d, -1.59d, 1.62d, -1.59d, -0.27d, 0.27d, 5.93d,
                        8.14d, -0.47d, 2.36d, 0.23d, 9.22d, -2.95d, 4.35d, -3.12, -0.43d, -4.54d, 2.71d, -1.98d, 2.25d, 0.88d, 0.22d,
                        0d, -1.52d, 2.2d, 0.86d, -0.43d, 4.73d, -1.44d, 4.37d, 3.59d, 1.73d, 0.76d, -4.51d, -1.71d, -4.45d, -5.06d,
                        -1.28d, 4.1d, 2.49d, 0d, -3.24d, -5.44d, -1.11d, 2.68d, 1.96d, -1.92d, 1.74d, 2.78d, -1.04d, 0.42d, 3.35d, -2.84d
                );
                break;
            case "501047"://全指证券
                rangeList = Arrays.asList(-9d);
                break;
            case "320007"://诺安成长
                rangeList = Arrays.asList(-10d);
                break;
            case "009314"://广发双擎
                rangeList = Arrays.asList(-3.34d, 0.41d);
                break;
            case "001156"://新能源
                rangeList = Arrays.asList(-3.98d, 1.03d);
                break;
            case "260108"://景顺长城
                rangeList = Arrays.asList(-1.43d, 0.66d);
                break;
            case "001475"://军工
                rangeList = Arrays.asList(-2.83d, 0.46d);
                break;
            case "003095"://中欧医疗
                rangeList = Arrays.asList(-1.24d, 1.00d);
                break;
            case "009163"://广发医疗
                rangeList = Arrays.asList(-1.42d, 0.67d);
                break;
            default:
                break;
        }
        return rangeList;
    }

    @Override
    public List<Double> getRangeListLimit(String stockKey, int limit) {
        List<Double> resultList = new ArrayList<>(limit);
        List<Double> rangeList = getRangeList(stockKey);

        if (rangeList.size() < limit) {
            for (int i = 0; i < (limit - rangeList.size()); i++) {
                resultList.add(0d);
            }
            resultList.addAll(rangeList);
            return resultList;
        }

        for (int i = rangeList.size() - 1; i >= 0; i--) {
            resultList.add(rangeList.get(i));
        }
        return resultList;
    }
}
